package jdbctest;

import java.sql.*;

/**
 * Created by Administrator on 2017/9/11.
 */
public class InsertTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        /*
        //1.加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.连接数据库
        Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3307/jdbc","root","123456");
        */
        Connection conn=ConnectionUtils.getConnection();//加载驱动和连接数据库已被封装
        //3.获得statement
        Statement statement=conn.createStatement();
        //4.执行sql(表中插入一条记录)
        /**
         * executeUpdate(String sql);用于执行sql中的insert,update,delete语句,不用接收
         * */
        String sql="insert into users values('6','le','657','man','2000','0514')";
        statement.executeUpdate(sql);
        //5.关闭资源
        statement.close();
        conn.close();
    }
}
